home *** CD-ROM | disk | FTP | other *** search
/ CD School House 9 / CD School House 9.0 - Wayzata Technology (1994).iso / pc / games / mac / __the_arcade__ / sea_hunt / card_2821.txt < prev    next >
Text File  |  1990-09-08  |  18KB  |  837 lines

  1. -- card: 2821 from stack: in
  2. -- bmap block id: 5666
  3. -- flags: 0000
  4. -- background id: 2774
  5. -- name: Computer Card
  6. ----- HyperTalk script -----
  7. --
  8. --
  9. --   This stack and it's scripts and graphics are copyright 1989,
  10. --   Prophecy Software Inc.  All rights reserved.
  11. --
  12. --   You may examine this code for your own benifit.
  13. --   If you wish to make changes that enhance the stack please make
  14. --   them to a copy and contact us at:
  15. --
  16. --   Prophecy Software Inc.
  17. --   3650 Silverside Rd. Suite 3
  18. --   Wilmington, DE 19810
  19. --   (302) 994-1502
  20. --
  21. --   We will be happy to consider distributing an updated version with
  22. --   propper credit given to the author.  distribution of copies of this
  23. --   stack with un-authorized alterations constitures copyright
  24. --   violation and fraud.
  25.  
  26. on com_turn
  27.  
  28.   global cbs, cca, ctt, csu, cpt, chit_count
  29.   global results, ship_up, game_active, opponent
  30.  
  31.  
  32.   put card field "data" of card "computer card" into the_message
  33.   put "" into card field "data" of card "computer card"
  34.   put word 1 of the_message into command
  35.  
  36.   -- message from player
  37.  
  38.   if command is "sm" then
  39.     get number of lines in card field "lines" of card "computer card"
  40.     get random(it)
  41.     get line it of card field "lines" of card "computer card"
  42.     get csend("sm" && it && "ΓÇó")
  43.     exit com_turn
  44.   end if
  45.  
  46.   -- only messages are active after the game is over.
  47.  
  48.   if game_active is false then exit com_turn
  49.  
  50.   -- move, query to ship at this location
  51.  
  52.   if command is "move" then
  53.     put word 2 of the_message into value
  54.     get field value of card "computer card"
  55.     put it into out_value
  56.  
  57.     if opponent is "CVSC" then
  58.       put "Incoming..." into card field 1 of card "enemy board"
  59.       put word 2 of the_message into value
  60.       if it is not "" then
  61.         push this card
  62.         go to card "player Card"
  63.         play boom
  64.         set icon of button value  to 7009
  65.         get flash ("Hit...")
  66.       else
  67.         push this card
  68.         go to card "player Card"
  69.         play splash
  70.         set icon of button value to 19123
  71.         get flash("Miss...")
  72.       end if
  73.     end if
  74.     get csend ("re" && value && out_value && "ΓÇó")
  75.  
  76.     exit com_turn
  77.   end if
  78.  
  79.   -- results, answer to a move query
  80.  
  81.   if command is "re" then
  82.     put word 2 of the_message into value
  83.     put word 3 of the_message into shot
  84.  
  85.     if opponent is "CVSC" then
  86.       push this card
  87.       go to card "enemy board"
  88.       if shot is not "ΓÇó" then
  89.         put "Tower Reports Hit.." into card field 1 of card "enemy board"
  90.         play boom
  91.         set icon of button value of card "enemy board" to 7009
  92.       else
  93.         put "Tower Reports Miss.." into card field 1 of card "enemy board"
  94.         play splash
  95.         set icon of button value of card "enemy board" to 19123
  96.       end if
  97.       pop card
  98.     end if
  99.  
  100.     if shot is not "ΓÇó" then
  101.       put shot && value into results
  102.       if shot is "B" then
  103.         add 1 to cbs
  104.         if cbs is 5 then
  105.           put done_test("B") into ship_up
  106.           put "" into results
  107.         end if
  108.       end if
  109.  
  110.       if shot is "C" then
  111.         add 1 to cca
  112.         if cca is 4 then
  113.           put done_test("C") into ship_up
  114.           put "" into results
  115.         end if
  116.       end if
  117.  
  118.       if shot is "T" then
  119.         add 1 to ctt
  120.         if ctt is 3 then
  121.           put done_test("T") into ship_up
  122.           put "" into results
  123.         end if
  124.       end if
  125.  
  126.       if shot is "S" then
  127.         add 1 to csu
  128.         if csu is 3 then
  129.           put done_test("S") into ship_up
  130.           put "" into results
  131.         end if
  132.       end if
  133.  
  134.       if shot is "P" then
  135.         add 1 to cpt
  136.         if cpt is 2 then
  137.           put done_test("P") into ship_up
  138.           put "" into results
  139.         end if
  140.       end if
  141.  
  142.       add 1 to chit_count
  143.       if chit_count is 17 then
  144.         get csend("win" && "ΓÇó")
  145.         put false into game_active
  146.         send idle to stack
  147.  
  148.         repeat with count = 1 to 64
  149.           get field count of card "computer card"
  150.           if it is not empty then
  151.             get csend("at" && count && "ΓÇó")
  152.             send idle to stack
  153.           end if
  154.         end repeat
  155.  
  156.  
  157.         exit com_turn
  158.       end if
  159.  
  160.     else put "" into results
  161.  
  162.     get csend ("go" && "ΓÇó")
  163.     exit com_turn
  164.   end if
  165.  
  166.   if command is "go" then
  167.     send find_move to card "computer card"
  168.  
  169.     exit com_turn
  170.   end if
  171.  
  172.   -- start determine who goes first
  173.  
  174.   if command is "st" then
  175.     put word 2 of the_message into value
  176.     if random(10) < value then
  177.       get  csend("go" && "ΓÇó")  -- other player goes first
  178.     else
  179.       get send_message("go" && "ΓÇó")
  180.     end if
  181.  
  182.     exit com_turn
  183.   end if
  184.  
  185.   if command is "win" then
  186.     put false into game_active
  187.     exit com_turn
  188.   end if
  189.  
  190.   if command is "done" then
  191.     exit com_turn
  192.   end if
  193.  
  194.   -- unknown command, send query
  195.  
  196. end com_turn
  197.  
  198. function csend the_message
  199. global opponent
  200. if opponent is "CVSC" then
  201.   get writemodem(the_message)
  202.   exit csend
  203. end if
  204.  
  205. put the_message into card field "message" of card "computer card"
  206. return 0
  207. end csend
  208.  
  209. on find_move
  210.  
  211.   global results, ship_up, where_at_now, direction
  212.   global pattern, active_ship, opponent
  213.  
  214.   -- pattern is a counter 1 to 64 looping that describes the
  215.   -- firing pattern of the computer
  216.   -- results is the results of our last shot
  217.   -- where at now is the location of where we last hit
  218.   -- active ship is what type of ship are we shelling.
  219.  
  220.   put word 1 of results into the_ship
  221.   put word 2 of results into where
  222.  
  223.   -- are we already shelling a ship?
  224.  
  225.   if ship_up is true then
  226.  
  227.     -- if we hit something, then that becomes our last hit
  228.     -- position and we look for a spot from there.
  229.  
  230.     if results is not empty then
  231.  
  232.       -- last shot was a hit, update location to reflect where
  233.       -- hit was.
  234.  
  235.       add direction to where_at_now
  236.  
  237.       -- if we have hit a new ship, then record it.
  238.       -- and start fresh shelling this ship.
  239.       -- we will return after it is sunk.
  240.       -- sort of a filo stack for ships.
  241.  
  242.       if active_ship is not the_ship then
  243.         put results && direction & numtochar(13) after card field "active" in card "computer card"
  244.         put the_ship into active_ship
  245.         put 1 into direction
  246.       else
  247.         put " " & direction into word 4 of last line of card field "Active" in card "computer card"
  248.       end if
  249.  
  250.     else
  251.  
  252.       -- we missed this time, but we have hit a ship, so
  253.       -- let's see if we have established it's direction yet
  254.       -- (word 4 of field active)  if so, then lets take the
  255.       -- initial hit location and reverse gears.
  256.  
  257.       get last line of card field active of card "computer card"
  258.       if it is not empty then
  259.         if word 4 of it is not empty then
  260.           put word 2 of it into move
  261.           put move into where_at_now
  262.           put word 4 of it into direction
  263.           put -1 * direction into direction
  264.           add direction to move
  265.         end if
  266.       end if
  267.  
  268.     end if
  269.  
  270.  
  271.   else
  272.  
  273.     -- test for first hit on ship, record it if it is.
  274.  
  275.     if results is not empty then
  276.       put true into ship_up
  277.       put where into where_at_now
  278.       put 1 into direction
  279.       put results && "1" & numtochar(13) after card field "active" in card "computer card"
  280.       put the_ship into active_ship
  281.  
  282.     end if
  283.   end if
  284.  
  285.   -- all right, we seem to think we need to find a new ship,
  286.   -- but first, lets just see...
  287.  
  288.   if ship_up is false then
  289.     put done_test("") into ship_up
  290.   end if
  291.  
  292.   if ship_up is true then
  293.     put xxx() into move
  294.     if move is not -1 then
  295.  
  296.       get csend("move" && move && "ΓÇó")
  297.       exit find_move
  298.     end if
  299.   end if
  300.  
  301.   --  here we are continuing the shelling pattern
  302.   --  which means we don't know where a ship is!
  303.  
  304.   put false into ok
  305.   put false into ship_up
  306.   put 1 into direction
  307.  
  308.   repeat until ok
  309.  
  310.     add 1 to pattern
  311.     if pattern is 65 then put 1 into pattern
  312.     put line pattern of card field "Pattern" of card "computer card" into move
  313.  
  314.     get icon of button move of card "Player Card"
  315.     if opponent is "CVSC" then
  316.       get icon of button move of card "Enemy Board"
  317.     end if
  318.  
  319.     if it is 0 then put true into ok
  320.   end repeat
  321.   get csend("move" && move && "ΓÇó")
  322.  
  323. end find_move
  324.  
  325. function xxx
  326.  
  327. global results, ship_up, where_at_now, direction, opponent
  328.  
  329. put false into ok
  330. put -1 into move
  331.  
  332. repeat until ok
  333.   put where_at_now + direction into test
  334.   if test < 1 or test > 64 then
  335.     get new_direction()
  336.   else
  337.  
  338.     get icon of button test of card "player card"
  339.     if opponent is "CVSC" then
  340.       get icon of button test of card "Enemy Board"
  341.     end if
  342.     if it is 0 then
  343.       put test into move
  344.       put true into ok
  345.     else
  346.       get new_direction()
  347.     end if
  348.  
  349.     -- test to make sure we do not circle forever.
  350.     -- at this point, we may have reversed direction on the ship
  351.     -- give one test at the negative direction of the last ship
  352.     -- in the active list, note, must have 4 words, meaning
  353.     -- that we have a known direction of the ship
  354.     -- this condition occures when we walk to one end of a ship
  355.     -- and all the spaces around it are already shelled.
  356.  
  357.     if direction is 1 and move is -1 then
  358.       get last line of card field active of card "computer card"
  359.       if it is not empty then
  360.         if word 4 of it is not empty then
  361.           put word 2 of it into move
  362.           put move into where_at_now
  363.           put word 4 of it into direction
  364.           put -1 * direction into direction
  365.           add direction to move
  366.         end if
  367.       end if
  368.       put true into ok
  369.     end if
  370.  
  371.   end if
  372.  
  373. end repeat
  374. return move
  375. end xxx
  376.  
  377. function new_direction
  378. global direction
  379.  
  380. if direction is 1 then
  381.   put 8 into direction
  382.   return 1
  383. end if
  384.  
  385. if direction is 8 then
  386.   put -1 into direction
  387.   return 1
  388. end if
  389.  
  390. if direction is -1 then
  391.   put -8 into direction
  392.   return 1
  393. end if
  394.  
  395. if direction is -8 then
  396.   put 1 into direction
  397.   return 1
  398. end if
  399.  
  400. end new_direction
  401.  
  402. on setup
  403.   put "Clearing..."  into card field status
  404.  
  405.   repeat with  count = 1 to  64
  406.     put "" into field count
  407.   end repeat
  408.  
  409.   put false into ok
  410.   put "Battle Ship" && numtochar(13) into card field status
  411.  
  412.   repeat until ok is true
  413.     put random(8) into h
  414.     put random(8) into v
  415.     put random(2) into angle
  416.     put put_ship(angle, 5, h, v, "B") into ok
  417.   end repeat
  418.  
  419.   put false into ok
  420.   put "Carrier" & numtochar(13) after card field status
  421.  
  422.   repeat until ok is true
  423.     put random(8) into h
  424.     put random(8) into v
  425.     put random(2) into angle
  426.     put put_ship(angle, 4, h, v, "C") into ok
  427.   end repeat
  428.  
  429.   put false into ok
  430.   put "Transport" & numtochar(13) after card field status
  431.  
  432.   repeat until ok is true
  433.     put random(8) into h
  434.     put random(8) into v
  435.     put random(2) into angle
  436.  
  437.     put put_ship(angle, 3, h, v, "T") into ok
  438.   end repeat
  439.  
  440.   put false into ok
  441.   put "Submarine" & numtochar(13) after card field status
  442.  
  443.   repeat until ok is true
  444.     put random(8) into h
  445.     put random(8) into v
  446.     put random(2) into angle
  447.  
  448.     put put_ship(angle, 3, h, v, "S") into ok
  449.   end repeat
  450.  
  451.   put false into ok
  452.   put "PT Boat" & numtochar(13) after card field status
  453.  
  454.   repeat until ok is true
  455.     put random(8) into h
  456.     put random(8) into v
  457.     put random(2) into angle
  458.  
  459.     put put_ship(angle, 2, h, v, "P") into ok
  460.   end repeat
  461.  
  462. end setup
  463.  
  464. function put_ship angle, length, h, v, letter
  465.  
  466. if angle is 1 then
  467.   if h + length - 1 > 8 then
  468.     return false
  469.     exit put_ship
  470.   end if
  471. else
  472.   if v + length - 1 > 8 then
  473.     return false
  474.     exit put_ship
  475.  
  476.   end if
  477. end if
  478. put (v - 1) * 8 + h into the_field
  479.  
  480. put the_field into temp_field
  481. repeat with  count = 1 to length
  482.   get field temp_field
  483.   if it is not "" and it is not letter then
  484.     return false
  485.     exit put_ship
  486.   end if
  487.  
  488.   if angle is 1 then
  489.     add 1 to temp_field
  490.   else
  491.     add 8 to temp_field
  492.   end if
  493. end repeat
  494.  
  495. put the_field into temp_field
  496.  
  497. repeat with count = 1 to length
  498.  
  499.   put letter into field temp_field
  500.   if angle is 1 then
  501.     add 1 to temp_field
  502.   else
  503.     add 8 to temp_field
  504.   end if
  505. end repeat
  506. return true
  507. end put_ship
  508.  
  509. function done_test the_letter
  510.  
  511. global results, ship_up, where_at_now, direction, active_ship
  512. global opponent
  513.  
  514. -- remove the ship sunk from the active roster, and
  515. -- return true if there are no other known unsunk ships
  516. -- if there are other unsunk ships then it is because we
  517. -- walked from one ship to another while shelling the first.
  518. -- we will return the "where_at_now" field to it's starting
  519. -- position
  520.  
  521. if the_letter is not "" then
  522.   put 1 into count
  523.   repeat while count < 6
  524.     get line count of card field "active" of card "computer card"
  525.     if first word of it is the_letter then
  526.       delete line count of card field "active" of card "computer card"
  527.     else
  528.       add 1 to count
  529.     end if
  530.  
  531.  
  532.   end repeat
  533. end if
  534.  
  535. get last line of card field "active" of card "computer card"
  536. if it is empty then return false
  537.  
  538. -- ok, we left a ship unsunk, reset the variables
  539. -- as if we had just made the last hit on it,
  540. -- that is which ship, where and direction, then
  541. -- do a quick test to see where the next un-tested
  542. -- space around here is.
  543.  
  544. put first word of it into active_ship
  545. put second word of it into where_at_now
  546. put third word of it into direction
  547. get new_direction()
  548.  
  549. -- find out if we've gone this way before.
  550. -- if so, keep swinging clockwise
  551.  
  552. put where_at_now + direction into temp
  553. if temp > 0 and temp < 65 then
  554.   get icon of button temp of card "player Card"
  555.   if opponent is "CVSC" then
  556.     get icon of button temp of card "Enemy Board"
  557.   end if
  558.   if it is not 0 then
  559.     get new_direction()
  560.   end if
  561. else   get new_direction()
  562.  
  563. put where_at_now + direction into temp
  564. if temp > 0 and temp < 65 then
  565.   get icon of button temp of card "player Card"
  566.   if opponent is "CVSC" then
  567.     get icon of button temp of card "Enemy Board"
  568.   end if
  569.   if it is not 0 then
  570.     get new_direction()
  571.   end if
  572. else   get new_direction()
  573.  
  574. put where_at_now + direction into temp
  575. if temp > 0 and temp < 65 then
  576.   get icon of button temp of card "player Card"
  577.   if opponent is "CVSC" then
  578.     get icon of button temp of card "Enemy Board"
  579.   end if
  580.   if it is not 0 then
  581.     get new_direction()
  582.   end if
  583. else   get new_direction()
  584.  
  585. return true
  586. end done_test
  587.  
  588.  
  589.  
  590.  
  591.  
  592. -- part 1 (field)
  593. -- low flags: 80
  594. -- high flags: 0004
  595. -- rect: left=182 top=22 right=57 bottom=445
  596. -- title width / last selected line: 0
  597. -- icon id / first selected line: 0 / 0
  598. -- text alignment: 0
  599. -- font id: 3
  600. -- text size: 12
  601. -- style flags: 0
  602. -- line height: 16
  603. -- part name: Data
  604.  
  605.  
  606. -- part 2 (field)
  607. -- low flags: 80
  608. -- high flags: 0004
  609. -- rect: left=183 top=59 right=94 bottom=446
  610. -- title width / last selected line: 0
  611. -- icon id / first selected line: 0 / 0
  612. -- text alignment: 0
  613. -- font id: 3
  614. -- text size: 12
  615. -- style flags: 0
  616. -- line height: 16
  617. -- part name: Message
  618.  
  619.  
  620. -- part 8 (field)
  621. -- low flags: 80
  622. -- high flags: 0007
  623. -- rect: left=69 top=23 right=328 bottom=146
  624. -- title width / last selected line: 0
  625. -- icon id / first selected line: 0 / 0
  626. -- text alignment: 0
  627. -- font id: 3
  628. -- text size: 12
  629. -- style flags: 0
  630. -- line height: 16
  631. -- part name: Pattern
  632.  
  633.  
  634. -- part 11 (field)
  635. -- low flags: 80
  636. -- high flags: 0004
  637. -- rect: left=308 top=185 right=287 bottom=506
  638. -- title width / last selected line: 0
  639. -- icon id / first selected line: 0 / 0
  640. -- text alignment: 0
  641. -- font id: 3
  642. -- text size: 12
  643. -- style flags: 0
  644. -- line height: 16
  645. -- part name: Active
  646.  
  647.  
  648. -- part 12 (field)
  649. -- low flags: 01
  650. -- high flags: 0002
  651. -- rect: left=192 top=183 right=264 bottom=320
  652. -- title width / last selected line: 0
  653. -- icon id / first selected line: 0 / 0
  654. -- text alignment: 0
  655. -- font id: 3
  656. -- text size: 12
  657. -- style flags: 0
  658. -- line height: 16
  659. -- part name: status
  660.  
  661.  
  662. -- part 13 (field)
  663. -- low flags: 80
  664. -- high flags: 0007
  665. -- rect: left=18 top=31 right=188 bottom=496
  666. -- title width / last selected line: 0
  667. -- icon id / first selected line: 0 / 0
  668. -- text alignment: 0
  669. -- font id: 3
  670. -- text size: 12
  671. -- style flags: 0
  672. -- line height: 16
  673. -- part name: lines
  674.  
  675.  
  676. -- part contents for card part 8
  677. ----- text -----
  678. 57
  679. 53
  680. 42
  681. 38
  682. 27
  683. 23
  684. 12
  685. 8
  686. 33
  687. 29
  688. 18
  689. 14
  690. 3
  691. 63
  692. 52
  693. 48
  694. 9
  695. 5
  696. 58
  697. 54
  698. 43
  699. 39
  700. 28
  701. 24
  702. 49
  703. 45
  704. 34
  705. 30
  706. 19
  707. 15
  708. 4
  709. 64
  710. 25
  711. 21
  712. 10
  713. 6
  714. 59
  715. 55
  716. 44
  717. 40
  718. 1
  719. 61
  720. 50
  721. 46
  722. 35
  723. 31
  724. 20
  725. 16
  726. 41
  727. 37
  728. 26
  729. 22
  730. 11
  731. 7
  732. 60
  733. 56
  734. 17
  735. 13
  736. 2
  737. 62
  738. 51
  739. 47
  740. 36
  741. 32
  742.  
  743.  
  744.  
  745.  
  746. -- part contents for card part 12
  747. ----- text -----
  748. Battle Ship 
  749. Carrier
  750. Transport
  751. Submarine
  752. PT Boat
  753.  
  754.  
  755. -- part contents for card part 13
  756. ----- text -----
  757. Ahh.. you Don't have Chance
  758. I have not yet begun to fight!
  759. Talking to a Computer even...
  760. A door is Ajar
  761. That does not compute.
  762. Why don't you go out and get some real friends?
  763. Warning! Warning! Warning!
  764. I Cheat!
  765. Hello, My name is Ralph.
  766. I'm Sorry, that number is no longer in Service
  767. I'm Sorry, The Computer is Out.
  768. Stay Tuned to this Channel.
  769. Stop Talking and get on with it.
  770.  
  771. -- part contents for background part 51
  772. ----- text -----
  773. B
  774.  
  775. -- part contents for background part 52
  776. ----- text -----
  777. B
  778.  
  779. -- part contents for background part 53
  780. ----- text -----
  781. B
  782.  
  783. -- part contents for background part 54
  784. ----- text -----
  785. B
  786.  
  787. -- part contents for background part 55
  788. ----- text -----
  789. B
  790.  
  791. -- part contents for background part 12
  792. ----- text -----
  793. C
  794.  
  795. -- part contents for background part 13
  796. ----- text -----
  797. C
  798.  
  799. -- part contents for background part 14
  800. ----- text -----
  801. C
  802.  
  803. -- part contents for background part 15
  804. ----- text -----
  805. C
  806.  
  807. -- part contents for background part 42
  808. ----- text -----
  809. T
  810.  
  811. -- part contents for background part 50
  812. ----- text -----
  813. T
  814.  
  815. -- part contents for background part 58
  816. ----- text -----
  817. T
  818.  
  819. -- part contents for background part 27
  820. ----- text -----
  821. S
  822.  
  823. -- part contents for background part 28
  824. ----- text -----
  825. S
  826.  
  827. -- part contents for background part 29
  828. ----- text -----
  829. S
  830.  
  831. -- part contents for background part 57
  832. ----- text -----
  833. P
  834.  
  835. -- part contents for background part 65
  836. ----- text -----
  837. P